<template>
    <div>
<h1>添加等级权益</h1>
<table class="table table-bordered" border="1">
    <tr>
        <td>等级</td>
        <td><select v-model="ad.rank_Id">
            <option value="0">请选择</option>
            <option v-for="item in dj" :value="item.rank_id">{{item.rank_name}}</option>
     
        </select></td>
    </tr>   

    <tr>
        <td>权益</td>
        <td><select v-model="ad.rR_id">
            <option value="0">请选择</option>
            <option v-for="item in qy" :value="item.mr_id">{{item.mr_name}}</option>
         
        </select></td>
    </tr>

    <tr>
        <td></td>
        <td><input type="button" value="注册" @click="pdadd"></td>
    </tr>
</table>


    </div>
</template>

<script setup lang="ts">
import { onMounted, ref} from "vue";
import axios from "axios";

const ad=ref({


    rankeey_Id: 0,
    rank_Id: 0,
    rR_id:0
})

const dj=ref([{

    rank_id: 0,
  rank_name: "",
  rank_zt: true,
  rank_min: 0,
  rank_max: 0


}])

const qy=ref([{

    mr_id: 0,
  mr_name: "",
  mr_sm: "",
  mr_zdy: true,
  mr_meiju: 0,
  mr_Rule: ""
    
}])

onMounted(()=>{

    pddj();
    pdqy();
})


const pddj=()=>{

axios.get('https://localhost:7268/api/hy/showmebertrankeinfo')

.then(res=>{

    dj.value=res.data;

})




}

const pdqy=()=>{

axios.get('https://localhost:7268/api/hy/showmeberRigaeninfo')


.then(res=>{

    qy.value=res.data;

})


}


const pdadd=()=>{

axios.post('https://localhost:7268/api/hy/addRanRigthsIfon',ad.value)


.then(res=>{
    if(res.data>0)
{
alert('注册成功');

}
else{

    alert('注册失败') ;
}


})
.catch(error=>{

console.log(error)

})

}


</script>

<style scoped>

</style>